
<div class="container">

    <?php
    include 'member-left.php';
    include 'member-right.php';
    ?>

    <div class="member_c">


        
        <?php if ($member->isOwner()) { ?>
            <script src="/js/tabs.js" type="text/javascript"></script>
            <div id="control_dis_stream">
                <ul>
                    <li><a <?php echo!$_GET['view'] ? 'class="active"' : ''; ?> href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>"><span>Cùng quê</span></a></li>
                    <li class="sub"><a <?php echo $_GET['view'] == 'group' ? 'class="active"' : ''; ?> href="javascript:;" ><span>Nhóm bạn</span><span class="arrow-bottom">&nbsp;</span></a>

                        <?php
                        $arrGroup = $member->getAllGroup();
                        if ($db->num_rows($arrGroup) > 0) {
                            echo '<ul >';
                            while ($row = $db->fetch_array($arrGroup)) {
                                ?>
                            <li><a href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>&view=group&gid=<?php echo $row['id']; ?>"><?php echo $row['group_name']; ?></a></li>
                            <?php
                        }
                        echo '</ul>';
                    }
                    ?>                        

                    </li>
                    <li><a <?php echo $_GET['view'] == 'private' ? 'class="active"' : ''; ?> href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>&view=private" ><span>Chỉ mình tôi</span></a></li>
                    <li style="display:none" id="filter-feed-loading"><img style="margin-top:5px;" src="/images/loading_h.gif"/></li>
                </ul>
            </div>
        <?php } ?>
        <div class="clear"></div>
        <div class="tab">
            <div class="tab-sub">
                <ul class="idTabs">
                    <li><a rel="status" class="share_tab status selected" href="#tab1" id="share-status"><b><span class="icon01 ico51 inline-block">&nbsp;</span>Trạng thái</b></a></li>
                    <li><a rel="uplink" class="share_tab uplink" href="#tab2" id="share-link"><b><span class="icon01 ico31 inline-block">&nbsp;</span>Liên kết</b></a></li>
                    <li><a rel="music" class="share_tab video" href="#tab3" id="share-photo"><b><span class="icon01 ico33 inline-block">&nbsp;</span>Nhạc/Video</b></a></li>
                </ul>
                <div class="clear"></div>
            </div>

            <div class="tab-content">
                <form name="shareform" enctype="multipart/form-data" method="post" action="#">
                    <input type="hidden" value="1" id="hcurrentmodule" name="hcurrentmodule"/>
                    <input type="hidden" value="4" id="hfk" name="hfk"/>
                    <input type="hidden" value="1" id="hfkt" name="hfkt"/>
                    <input type="hidden" value="index" id="hcurrentaction" name="hcurrentaction"/>
                    <input type="hidden" value="status" id="blastType" name="blastType"/>
                    <input type="hidden" value="Nhận xét về liên kết này" id="blastValue" name="blastValue"/>
                    <?php
                        if(trim($_GET['view'])=='' && intval($_GET['mid']!=$_SESSION['client']['id'])){
                            $share_for = 'private';
                        }else{
                            $share_for = trim($_GET['view']);
                        }
                    ?>
                    <input type="hidden" value="<?php echo $share_for;?>" id="share_for"/>
                    <div class="tab-content-main">
                        <!--Tab1-->
                        <div style="display: block;" id="tab1">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <input type="hidden" id="my_avatar" value="<?php echo $_SESSION['client']['avatar']; ?>"/>
                                <textarea id="comment" >Bạn đang nghĩ gì?</textarea>
                                <span >
                                    <input type="button" class="btnBlogComment" id="btnBlogComment" value="Chia sẻ"/>
                                </span>
                            </div>
                        </div>
                        <!--Tab2-->
                        <div style="display:none;" id="tab2">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <div id="usharelinkform" class="sub-section infosubsection" style="display: block;">
                                    <div class="sub-section-main"  >
                                        <ul>
                                            <li class="label">
                                                <h3>Liên kết:</h3>
                                            </li>
                                            <li>
                                                <input type="text" id="postLink1" class="general w350" >&nbsp;&nbsp;
                                            </li>
                                        </ul>
                                        <div class="left">

                                            <img id="imgLoadingAttachLink1" class="waiting" src="/images/waiting.gif" alt="Đang tải..." style=" display: none;"/>
                                            <input type="button" id="attach_link1" value="Duyệt" class="button">
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                    <div class="imageThumb">
                                        <div id="image-link-thumb"></div>
                                        <div style="display:none" class="btnplay"><img width="1" height="1" src="/images/blank_img.gif" alt="" class="play-btn-class"></div>
                                    </div>
                                    <div class="link-content">
                                        <div id="linkTitle" class="title" ></div>
                                        <div id="linkDescription" class="description"></div>
                                        <div class="thumb-controll">
                                            <span class="nextPre">
                                                <a  class="prev" href="javascript:;">&nbsp;</a><a  class="next" href="javascript:;">&nbsp;</a>
                                                <span id="positioncurimg">1</span> / <span id="totalimg"></span>
                                                &nbsp;Chọn hình tượng trưng<br>
                                            </span>
                                            <span class="nothumb"><input type="checkbox"  id="no-thump" name="no-thump" value=""> Không dùng hình tượng trưng</span>
                                        </div>
                                    </div>

                                    <textarea id="commentLink">Viết gì thêm đi nhỉ!</textarea>
                                    <span >
                                        <img id="imgLoadingShareLink1" src="/images/loading_small.gif" alt="Đang tải..." style="height: 30px;display: none;"/>
                                        <input type="button" class="btnBlogComment" id="btnBlogShareLink1" value="Chia sẻ" style="display: none;"/>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <!--Tab3-->
                        <div style="display: none;" id="tab3">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <div id="usharelinkform" class="sub-section infosubsection" style="display: block;">
                                    <div class="sub-section-main"  style="margin-bottom: 10px">
                                        <ul>
                                            <li class="label">
                                                <h3>Mã nhúng:</h3>
                                            </li>
                                            <li>
                                                <textarea id="postEmbed" class="general w255" name="lienket" style="height: 50px" ></textarea>
                                            </li>
                                        </ul>
                                        <div class="clear"></div>
                                    </div>
                                    <textarea  id="commentEmbed">Viết gì thêm đi nhỉ!</textarea>
                                    <span >
                                        <img id="imgLoadingShareEmbed" src="/images/loading_small.gif" alt="Đang tải..." style="height: 30px;display: none;"/>
                                        <input type="button" class="btnBlogComment" id="btnBlogShareEmbed" value="Chia sẻ"/>
                                    </span>
                                </div>
                            </div>
                        </div>


                    </div>

                </form>
            </div>
        </div>


        <div class="listnews">
            <?php
            $showTotal = 20;
            $listComment = $stream->listComment($showTotal);

            if ($listComment['rs']) {
                ?>
                <ul id="displayBlogComment">
                    <?php
                    while ($row = $db->fetch_array($listComment['rs'])) {
                        $last_id = $row['id'];
                        $member_info = $member->getById(intval($row['mid']));
                        $listChildComment = $stream->listChildComment($row['id']);
                        
                            ?>
                            <li id="comment_<?php echo $row['id']; ?>">
                                <div class="divBlogCommentMain">
                                    <div class="avatar1">
                                        <a href="/thanh-vien?mid=<?php echo $member_info['id']; ?>&view=private" title="<?php echo $member_info['fullname']; ?>">
                                            <img src="<?php echo $common->get_avatar_thumb($member_info['avatar']); ?>" width="50" />
                                        </a>
                                    </div>
                                    <div class="comment1">
                                        <p>
                                            <a href="/thanh-vien?mid=<?php echo $member_info['id']; ?>&view=private"  title="<?php echo $member_info['fullname']; ?>"><b><?php echo $member_info['fullname']; echo $row['type']!=3?':':'' ?></b></a>
                                            <?php
                                            if ($row['type'] == 1) {//lien ket
                                                $arrContent = explode('$$$$$', $row['content']);
                                                echo $arrContent[4] ? $arrContent[4] . '<br >' : '<br>';
                                                if ($arrContent[0] != "" && $arrContent[0] != "undefined")
                                                    echo' <a target="_blank" href="' . $arrContent[2] . '" title="' . $arrContent[1] . '" ><img src="' . $arrContent[0] . '" width="130" height="100" > </a>';
                                                echo '<span class="linktitle"><a target="_blank" href="' . $arrContent[2] . '" title="' . $arrContent[1] . '" >' . $arrContent[1] . '</a></span><span >' . $arrContent[3] . '</span>';
                                            } elseif ($row['type'] == 2) {//ma nhung
                                                $arrContentEmbed = explode('$$$$$', $row['content']);
                                                echo $arrContentEmbed[1] ? $arrContentEmbed[1] . '<div class="clear"></div>' : '<div class="clear"></div>';
                                                echo $arrContentEmbed[0];
                                            } elseif ($row['type'] == 3) {//notify image
                                                $arrImgNotify = explode('$$$$$', $row['content']);
                                                $rsImg = $member->getNotifyImage(intval($arrImgNotify[0]),trim($arrImgNotify[1]));
                                                if ($rsImg) {
                                                    $contentImgNotify = "";
                                                    while ($rowImg = $db->fetch_array($rsImg)) {
                                                        $imgId = $rowImg['id'];
                                                        $imgMid = $rowImg['mid'];
                                                        $imgAid = $arrImgNotify[2];
                                                        $imgAName = $arrImgNotify[3];
                                                        $imgThumb = $rowImg['image'];
                                                        $contentImgNotify .= "<a href=\"/thanh-vien?mid=$imgMid&aid=$imgAid&image_id=$imgId&action=xemanh\"><img src=\"$imgThumb\" /></a>";
                                                    }
                                                    echo " đã thêm ảnh vào album <a href=\"/thanh-vien?mid=$imgMid&aid=$imgAid&action=anhcuatoi\">$imgAName</a><br/>".$contentImgNotify;
                                                }
                                            } else {
                                                echo $row['content'];
                                            }
                                            ?>
                                        </p>
                                        <div class="w_100 left">

                                            <span id="like_<?php echo $row['id']; ?>" class="<?php
                                if (strpos($row['likes'], "|" . $_SESSION["client"]['id'] . "|") === false)
                                    echo 'like'; else
                                    echo 'liked';
                                            ?>" title="Thích" onclick="likeThis('<?php echo $row['id']; ?>')"></span><span class="sendDate"><?php echo $date_fomat->diff(strtotime($row['create_date'])); ?><b><a href="javascript:setFocusComment('<?php echo $row['id']; ?>');">Bình luận</a></b></span></div>
                                    </div>

                                </div>
                                <!--
                                <?php
                                if (!$listChildComment['rs']) {
                                    ?>
                                                                                    <div class="divPostSubCommnet">
                                                                                        <textarea id="commentCon_<?php echo $row['id']; ?>" class="commentCon" >Viết bình luận...</textarea>
                                                                                        <input class="btnBlogComment" type="button" onclick="submitChildComment(<?php echo $row['id']; ?>);" value="Chia sẻ"/>
                                                                                    </div>
                                    <?php
                                }
                                ?>
                                -->
                                <?php
                                if ($listChildComment['rs']) {
                                    ?>
                                    <div  id="divListSubComment_<?php echo $row['id']; ?>">
                                        <?php
                                        while ($rowChild = $db->fetch_array($listChildComment['rs'])) {
                                            $memberChildInfo = $member->getById(intval($rowChild['mid']));
                                            ?>
                                            <div id="subComment_<?php echo $rowChild['id']; ?>" class="divSubBlogComment highlight">
                                                <div class="avatar2">
                                                    <a href="/thanh-vien?mid=<?php echo $memberChildInfo['id']; ?>&view=private" title="<?php echo $memberChildInfo['fullname']; ?>">
                                                        <img src="<?php echo $common->get_avatar_thumb($memberChildInfo['avatar']); ?>" width="32" />
                                                    </a>
                                                </div>
                                                <div class="comment2">
                                                    <a href="/thanh-vien?mid=<?php echo $memberChildInfo['id']; ?>&view=private" title="<?php echo $memberChildInfo['fullname']; ?>"><b><?php echo $memberChildInfo['fullname']; ?>:</b></a>
                                                    <?php echo $rowChild['content']; ?>
                                                    <br/>
                                                    <div class="w_100 left ">
                                                        <span class="sendDate"><?php echo $date_fomat->diff(strtotime($rowChild['create_date'])); ?></span> <span class="like" id="like_<?php echo $rowChild['id']; ?>" title="Thích" onclick="likeThis('<?php echo $rowChild['id']; ?>')"></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php
                                        }
                                        ?>
                                        <div class="divSubBlogComment highlight"  <?php
                        if ($db->num_rows($listChildComment['rs']) == 0) {
                            echo 'style="display:none"';
                        }
                                        ?> >
                                            <textarea style="height: 16px" id="commentCon_<?php echo $row['id']; ?>" class="commentCon" >Viết bình luận...</textarea>
                                            <span class="spanSubmitComment">
                                                <input type="button" class="btnBlogComment" onclick="submitChildComment(<?php echo $row['id']; ?>);" value="Bình luận"/>
                                            </span>
                                        </div>    
                                    </div>
                                    <?php
                                }
                                ?>
                            </li>
                            <?php
                        
                    }
                    ?>
                </ul>
                <?php
            }
            ?>
            <input type="hidden" id="last_id" value="<?php echo $last_id; ?>"/>
            <input type="hidden" id="mid" value="<?php echo intval($_GET['mid']); ?>"/>
            <input type="hidden" id="view" value="<?php echo trim($_GET['view']); ?>"/>
            <?php
            if (trim($_GET['view']) == 'group') {
                echo '<input type="hidden" id="group_id" value="' . intval($_GET['group_id']) . '"/>';
            }
            ?>
            <?php
            if ($db->num_rows($listComment['rs'])==$showTotal) {
                ?>
                <div class="btnmore" ><a href="javascript:;" id="aBlogLoadMore">Xem thêm<img src="/images/down_arrow.png"></a><img src="/images/waiting.gif" id="waiting" alt="" class="waiting"></div>
                    <?php } ?>
        </div>


    </div>

</div>
<script src="/js/home.js" type="text/javascript"></script>
